package week04;

	import java.util.Arrays;
	import java.util.Scanner;

	abstract class Shape {
		double PI = 3.14;

		public abstract double getPerimeter();

		public abstract double getArea();

	}

	class Rectangle extends Shape {
		private int width;
		private int length;

		public Rectangle(int width, int length) {
			this.width = width;
			this.length = length;
		}

		@Override
		public String toString() {
			return "Rectangle [width=" + width + ", length=" + length + "]";
		}

		public double getPerimeter() {
			return (width + length) * 2;
		}

		public double getArea() {
			return width * length;
		}
	}

	class Circle extends Shape {
		private int radius;

		public Circle(int radius) {
			this.radius = radius;
		}

		@Override
		public String toString() {
			return "Circle [radius=" + radius + "]";
		}

		public double getPerimeter() {
			return (2 * PI * radius);
		}

		public double getArea() {
			return (PI * radius * radius);
		}
	}

	public class week0401 {

		static double sumAllArea(Shape[] a) {
			double ans = 0;
			for (Shape shape : a) {
				ans += shape.getArea();
			}
			return ans;
		}

		static double sumAllPerimeter(Shape[] a) {
			double ans = 0;
			for (Shape shape : a) {
				ans += shape.getPerimeter();
			}
			return ans;
		}

		public static void main(String[] args) {
			Scanner in = new Scanner(System.in);
			int n = in.nextInt();
			Shape[] a = new Shape[n];
			for (int i = 0; i < n; i++) {
				String temp = in.next();
				if (temp.equals("rect")) {
					int t1 = in.nextInt();
					int t2 = in.nextInt();
					a[i] = new Rectangle(t1, t2);
				} else {
					int t = in.nextInt();
					a[i] = new Circle(t);
				}
			}
			System.out.println(sumAllPerimeter(a));
			System.out.println(sumAllArea(a));
			System.out.println(Arrays.deepToString(a));
			for (Shape shape : a) {
				System.out.println(shape.getClass() + "," + shape.getClass().getSuperclass());
			}

		}
	}

